const conditionOption = {
    menuBtn: false,
    column: [
        {
            prop: "type",
            type: "select",
            label: "流转类型",
            dicData: [
                {label: "默认流转路径", value: "default"},
                {label: "普通流转路径", value: "normal"},
                {label: "条件流转路径", value: "condition"},
            ],
            span: 24,
            control: (val, formModel) => {
                if (["normal", "default"].includes(val)) {
                    formModel.conditionType = "";
                    formModel.language = "";
                    formModel.scriptType = "";
                    formModel.body = "";
                    formModel.resource = "";
                    return {
                        conditionType: {
                            display: false
                        },
                        language: {
                            display: false
                        },
                        scriptType: {
                            display: false
                        },
                        body: {
                            display: false
                        },
                        resource: {
                            display: false
                        },
                    }
                }
                return {
                    conditionType: {
                        display: true,
                    }
                }
            }
        },
        {
            prop: "conditionType",
            type: "select",
            label: "条件格式",
            span: 24,
            dicData: [
                {label: "表达式", value: "expression"},
                {label: "脚本", value: "script"},
            ],
            control: (val, formModel) => {
                if (val === "script") {
                    formModel.resource = ""
                    return {
                        scriptType: {
                            display: true,
                        },
                        language: {
                            display: true,
                        },
                        resource: {
                            display: false,
                        },
                    }
                } else if (val === 'expression') {
                    formModel.language = ""
                    formModel.scriptType = ""
                    formModel.resource = ""
                    return {
                        body: {
                            display: true,
                        },
                        language: {
                            display: false,
                        },
                        scriptType: {
                            display: false,
                        },
                        resource: {
                            display: false,
                        },
                    }
                }
                return {}

            }
        },
        {
            prop: "language",
            label: "语言",
            type: "input",
            span: 24,
        }, {
            prop: "scriptType",
            label: "脚本类型",
            type: "select",
            span: 24,
            dicData: [
                {label: "内联脚本", value: "inlineScript"},
                {label: "外部脚本", value: "externalScript"},
            ],
            control: (val, formModel) => {
                if (val === 'inlineScript') {
                    formModel.resource = ""
                    return {
                        body: {
                            display: true,
                        },
                        resource: {
                            display: false,
                        }

                    }
                }
                if (val === 'externalScript') {
                    formModel.body = ""
                    return {
                        body: {
                            display: false,
                        },
                        resource: {
                            display: true,
                        }
                    }
                }
                return {}
            }
        },

        {
            span: 24,
            prop: "body",
            label: "表达式",
            type: "textarea",
        },
        {
            span: 24,
            prop: "resource",
            label: "资源地址",
            type: "input",
        },
    ]

}

function getOption(changeForm) {
    if (!changeForm) {
        return conditionOption
    }
    let tempOption = conditionOption;
    for (let i = 0; i < tempOption.column.length; i++) {
        tempOption.column[i].change = changeForm;
    }
    return tempOption;
}

const flowConditionOption = {
    getOption
}

export default flowConditionOption